using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class online_survey_answer_lineMap : EntityTypeConfiguration<online_survey_answer_line>
    {
        public online_survey_answer_lineMap()
        {
            // Primary Key
            this.HasKey(t => t.online_survey_answer_id);

            // Properties
            this.Property(t => t.answer)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.score)
                .IsFixedLength()
                .HasMaxLength(18);

            this.Property(t => t.answer_comments)
                .HasMaxLength(80);

            this.Property(t => t.User_ID)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("online_survey_answer_line");
            this.Property(t => t.online_survey_answer_id).HasColumnName("online_survey_answer_id");
            this.Property(t => t.answer).HasColumnName("answer");
            this.Property(t => t.score).HasColumnName("score");
            this.Property(t => t.online_survey_id).HasColumnName("online_survey_id");
            this.Property(t => t.survey_question_sheet_id).HasColumnName("survey_question_sheet_id");
            this.Property(t => t.answer_comments).HasColumnName("answer_comments");
            this.Property(t => t.User_ID).HasColumnName("User_ID");
            this.Property(t => t.answer_time).HasColumnName("answer_time");

            // Relationships
            this.HasOptional(t => t.online_survey)
                .WithMany(t => t.online_survey_answer_line)
                .HasForeignKey(d => d.online_survey_id);
            this.HasOptional(t => t.online_survey_question_sheet)
                .WithMany(t => t.online_survey_answer_line)
                .HasForeignKey(d => d.survey_question_sheet_id);
            this.HasOptional(t => t.user)
                .WithMany(t => t.online_survey_answer_line)
                .HasForeignKey(d => d.User_ID);

        }
    }
}
